package com.jy.appmarket.screenlock.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

import com.jy.appmarket.R;
import com.umeng.analytics.MobclickAgent;

/**
 * 类说明：
 * 
 * @author jie.li
 * @date 2015-3-5
 * @version 1.0
 */
public class SingleChoiceDialogActivity extends Activity implements OnClickListener {
	public static final String CONTENT_UP = "dialog_content_up";
	public static final String CONTENT = "dialog_content";
	public static final String TITLE = "dialog_title";
	private String mContent, mContentUp;
	private String mTitle;

	public static void startSingleChoiceDialogActivity(Context c, String title, String contentUp, String content) {
		Intent intent = new Intent(c, SingleChoiceDialogActivity.class);
		// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		Bundle b = new Bundle();
		b.putString(CONTENT_UP, contentUp);
		b.putString(CONTENT, content);
		b.putString(TITLE, title);
		intent.putExtras(b);
		c.startActivity(intent);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_single_choice_dialog);

		getIntentData();
		initView();
	}

	private void initView() {
		// Button b1 = (Button) findViewById(R.id.text_dialog_button1);
		Button b2 = findViewById(R.id.text_dialog_button2);
		// b1.setVisibility(View.GONE);
		b2.setText(R.string.understand);
		// b1.setOnClickListener(this);
		b2.setOnClickListener(this);
		TextView title = findViewById(R.id.text_dialog_title_tv);
		if (mTitle != null) {
			title.setText(mTitle);
		}
		TextView content = findViewById(R.id.text_dialog_content_tv);
		if (mContent != null) {
			content.setVisibility(View.VISIBLE);
			content.setText(mContent);
		}
		TextView contentUp = findViewById(R.id.text_dialog_content_up_tv);
		if (mContentUp != null) {
			contentUp.setVisibility(View.VISIBLE);
			contentUp.setText(mContentUp);
		}

	}

	private void getIntentData() {
		Intent intent = getIntent();
		Bundle b = intent.getExtras();
		mContent = b.getString(CONTENT);
		mContentUp = b.getString(CONTENT_UP);
		mTitle = b.getString(TITLE);

	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.text_dialog_button2:
			finish();
			break;

		default:
			break;
		}
	}

	@Override
	public void finish() {
		setResult(RESULT_OK);
		super.finish();
	}

	@Override
	protected void onResume() {
		super.onResume();
		MobclickAgent.onResume(this);
	}

	@Override
	protected void onPause() {
		super.onPause();
		MobclickAgent.onPause(this);
	}
}
